﻿using System.DirectoryServices.AccountManagement;

namespace Sunyi.Project.WebPoint.Common
{
    public class AdHelper
    {
        public static bool ValidateDomainUser(string userName, string password, string domain)
        {
            bool flag = false;

            if (!string.IsNullOrEmpty(password))
            {
                using (PrincipalContext context = new PrincipalContext(ContextType.Domain, domain))
                {
                    flag = context.ValidateCredentials(userName, password);
                }
            }

            return flag;
        }
    }
}